home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UDesignator.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  9.7 KB  |  287 lines  |  [TEXT/MPS ]

  1. // UDesignator.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UDESIGNATOR__
  5. #define __UDESIGNATOR__
  6.  
  7. //----------------------------------------------------------------------------------------
  8. // OVERVIEW
  9. // ========
  10. // TDesignator is designed as an abstract superclass which designates a portion of the
  11. // document. Each specialized document will require its own specialized designator.
  12. // Specialized subclasses of TDesignator are required to designate portions of different
  13. // documents.
  14. //  
  15. // CLASS HIERARCHY
  16. // ===============
  17. // TDesignator            abstract superclass for designators
  18. // TLinearDesignator    a linear data designator (e.g. for text models)
  19. // TRectDesignator        a rectangular designator (e.g. for spreadsheet models)
  20. // TRgnDesignator        a region designator (e.g. for discontiguous designations)
  21. //
  22. // USAGE
  23. // =====
  24. // TDesignator is used with the Edition Manager support that is built into MacApp.
  25. // Whenever a TSection object is instantiated, it requires a TDesignator object that lets
  26. // the TSection object determine which portion of the document is being designated as a
  27. // section, whether a publisher or a subscriber.
  28. //----------------------------------------------------------------------------------------
  29.  
  30. // MacApp
  31.  
  32. #ifndef __UGEOMETRY__
  33. #include "UGeometry.h"
  34. #endif
  35.  
  36. #ifndef __UOBJECT__
  37. #include "UObject.h"
  38. #endif
  39.  
  40. #ifndef __USCRIPTABLEOBJECT__
  41. #include "UScriptableObject.h"
  42. #endif
  43.  
  44. // Toolbox
  45.  
  46. #ifndef __MEMORY__
  47. #include <Memory.h>
  48. #endif
  49.  
  50. #ifndef __QUICKDRAW__
  51. #include <Quickdraw.h>
  52. #endif
  53.  
  54. //----------------------------------------------------------------------------------------
  55. // Containment constants
  56. //----------------------------------------------------------------------------------------
  57.  
  58. enum ContainmentType { kNotContained, kPartiallyContained, kExactlyContained, kFullyContained };
  59.  
  60. //----------------------------------------------------------------------------------------
  61. // Object Signtures: These follow the same reservation rules as resource types. The
  62. // signature is used to search the signature table and create an object "by signature"If
  63. // the signature's entry in the table has been updated with a new class then an object of
  64. // that class will be created.
  65. //----------------------------------------------------------------------------------------
  66.  
  67. const IDType kLinearDesignator = 'ldsg';
  68.  
  69. const IDType kVRectDesignator = 'vdsg';
  70.  
  71. const IDType kRegionDesignator = 'rdsg';
  72.  
  73. //----------------------------------------------------------------------------------------
  74. // Forward and external class declarations. 
  75. //----------------------------------------------------------------------------------------
  76.  
  77. class TStream;
  78.  
  79. //----------------------------------------------------------------------------------------
  80. // TDesignator: is designed as an abstract superclass. Use subclasses of TDesignator.
  81. //----------------------------------------------------------------------------------------
  82.  
  83. class TDesignator : public TObject, public MScriptableObject
  84. {
  85.     MA_DECLARE_CLASS;
  86.     
  87. public:
  88.     //----------------------------------------------------------------------------------------
  89.     // • contructors/destructors
  90.     //----------------------------------------------------------------------------------------
  91.  
  92.     TDesignator();
  93.         // Empty constructor to satisfy compiler.
  94.     virtual ~TDesignator();
  95.         // Destructor
  96.         
  97.     void IDesignator();
  98.         // initialize this object
  99.  
  100.     //----------------------------------------------------------------------------------------
  101.     // • utility methods
  102.     //----------------------------------------------------------------------------------------
  103.  
  104.     virtual Size GetSize();
  105.         // returns the size of this designation
  106.  
  107.     virtual ContainmentType IsContained(TDesignator* aDesignator);
  108.         // Override this; returns a ContainmentType indicating to what extent aDesignator
  109.         // is contained in this
  110.  
  111.     virtual Boolean IsEmpty();
  112.         // Returns false if the size of this designation is greater than 0
  113.  
  114. };
  115.  
  116.  
  117. //----------------------------------------------------------------------------------------
  118. // TLinearDesignator: is designed to designate any linear portion of data that may be
  119. // designated by a start position and an end position.
  120. //----------------------------------------------------------------------------------------
  121.  
  122. class TLinearDesignator : public TDesignator
  123. {
  124.     MA_DECLARE_CLASS;
  125.     
  126. public:
  127.     long fStartPos;                                // offset to start
  128.     
  129.     long fEndPos;                                // offset to end
  130.  
  131.     //----------------------------------------------------------------------------------------
  132.     // • contructors/ destructors
  133.     //----------------------------------------------------------------------------------------
  134.  
  135.     TLinearDesignator();
  136.         // Constructor
  137.     virtual ~TLinearDesignator();
  138.         // Destructor
  139.         
  140.     void ILinearDesignator(long startPos,
  141.                                           long endPos);
  142.         // initialize this object
  143.  
  144.     //----------------------------------------------------------------------------------------
  145.     // • utility methods
  146.     //----------------------------------------------------------------------------------------
  147.  
  148.     virtual IDType GetStandardSignature();
  149.         // returns the signature for this class
  150.  
  151.     virtual Size GetSize();
  152.         // returns the size of this designation
  153.  
  154.     virtual ContainmentType IsContained(TDesignator* aDesignator);
  155.         // OVERRIDE this; returns a ContainmentType indicating to what extent aDesignator
  156.         // is contained in this
  157.  
  158.     //----------------------------------------------------------------------------------------
  159.     // • saving
  160.     //----------------------------------------------------------------------------------------
  161.  
  162.     virtual void WriteTo(TStream* aStream);
  163.         // OVERRIDE this; writes specification of designator to stream
  164.  
  165.     virtual void ReadFrom(TStream* aStream);
  166.         // initializes this object from a stream specification
  167.  
  168. };
  169.  
  170.  
  171. //----------------------------------------------------------------------------------------
  172. // TVRectDesignator: is designed to designate any rectangular portion of data that may be
  173. // designated by top, left, bottom, and right VCoordinates.
  174. //----------------------------------------------------------------------------------------
  175.  
  176. class TVRectDesignator : public TDesignator
  177. {
  178.     MA_DECLARE_CLASS;
  179.     
  180. public:
  181.     VRect fDesignation;                            // VRect representing designation
  182.  
  183.     //----------------------------------------------------------------------------------------
  184.     // • contructors/destructors
  185.     //----------------------------------------------------------------------------------------
  186.  
  187.     TVRectDesignator();
  188.         // Constructor
  189.     virtual ~TVRectDesignator();
  190.         // Destructor
  191.         
  192.     void IVRectDesignator(const VRect& itsDesignation);
  193.         // initialize this object
  194.  
  195.     //----------------------------------------------------------------------------------------
  196.     // • utility methods
  197.     //----------------------------------------------------------------------------------------
  198.  
  199.     virtual IDType GetStandardSignature();
  200.         // returns the signature for this class
  201.  
  202.     virtual Size GetSize();
  203.         // returns the size of this designation
  204.  
  205.     virtual ContainmentType IsContained(TDesignator* aDesignator);
  206.         // OVERRIDE this; returns a ContainmentType indicating to what extent aDesignator
  207.         // is contained in this
  208.  
  209.     //----------------------------------------------------------------------------------------
  210.     // • saving
  211.     //----------------------------------------------------------------------------------------
  212.  
  213.     virtual void WriteTo(TStream* aStream);
  214.         // OVERRIDE this; writes specification of designator to stream
  215.  
  216.     virtual void ReadFrom(TStream* aStream);
  217.         // initializes this object from a stream specification
  218.  
  219. };
  220.  
  221.  
  222. //----------------------------------------------------------------------------------------
  223. // TRegionDesignator: is designed to designate any portion of data that may be designated by
  224. // a region. The caller must create the region, and the designator optionally frees the
  225. // region. In general, the TStream passed into this object should be a THandleStream.
  226. //----------------------------------------------------------------------------------------
  227.  
  228. class TRegionDesignator : public TDesignator
  229. {
  230.     MA_DECLARE_CLASS;
  231.     
  232. public:
  233.     RgnHandle fDesignation;                        // rgn representing designation
  234.  
  235.     Boolean fFreeRegionOnFree;                    // whether to free the RgnHandle when this
  236.                                                 // designator is freed
  237.  
  238.     //----------------------------------------------------------------------------------------
  239.     // • contructors/destructors
  240.     //----------------------------------------------------------------------------------------
  241.  
  242.     TRegionDesignator();
  243.         // Constructor
  244.         
  245.     void IRegionDesignator(RgnHandle itsDesignation,
  246.                                        Boolean freeRegionOnFree);
  247.         // Initialize this object.
  248.  
  249.     virtual ~TRegionDesignator();
  250.         // Frees fDesignation and calls Inherited::Free.
  251.  
  252.     virtual TObject* Clone();
  253.         // Calls Inherited::Clone, creates a copy of fDesignation rgn.
  254.  
  255.  
  256.     //----------------------------------------------------------------------------------------
  257.     // • utility methods
  258.     //----------------------------------------------------------------------------------------
  259.  
  260.     virtual IDType GetStandardSignature();
  261.         // returns the signature for this class
  262.  
  263.     virtual Size GetSize();
  264.         // returns the size of this designation
  265.  
  266.     virtual ContainmentType IsContained(TDesignator* aDesignator);
  267.         // returns a ContainmentType indicating to what extent aDesignator is contained in this
  268.  
  269.     virtual void SetDesignationRect(const CRect& theDesignation);
  270.         // sets fDesignation to contain this rectangle
  271.  
  272.     //----------------------------------------------------------------------------------------
  273.     // • saving
  274.     //----------------------------------------------------------------------------------------
  275.  
  276.     virtual void WriteTo(TStream* aStream);
  277.         // OVERRIDE this; writes specification of designator to stream
  278.  
  279.     virtual void ReadFrom(TStream* aStream);
  280.         // initializes this object from a stream specification
  281. };
  282.  
  283.  
  284. #endif
  285.  
  286.  
  287.